public class CSeqQueue<E> {
    E[] data;
    int head;
    int tail;

    public CSeqQueue() {
        data = (E[])new Object[10];
        head = 0;
        tail = 0;
    }

    public boolean empty(){
        return head==tail;
    }

    public void push(E e) {
        int pos = (tail + 1) % data.length;
        if (pos == head) {
            throw new IllegalArgumentException("队列溢出");
        }else {
            tail = pos;
            data[tail] = e;
        }
    }

    public E pop(){
        if(empty()){
            return null;
        }else {
            int ret = head;
            head = (head + 1) % data.length;
            return data[head];
        }
    }

    public E top(){
        if(empty()){
            return null;
        }else{
            return data[head];
        }
    }

}
